import { ref } from "vue"

export const fieldNumberFormats = [
  { value: "", label: "自动" },
  { value: "INT", label: "整形" },
  { value: "FLOAT1", label: "保留一位小数" },
  { value: "FLOAT2", label: "保留二位小数" },
  { value: "PERCENT", label: "百分比" },
  { value: "PERCENT1", label: "百分比一位小数" },
  { value: "PERCENT2", label: "百分比两位小数" },
  { value: "CUSTOM", label: "自定义公式" }
]
export const defaultFieldExtJson = {
  numberDataFormatOperator: "1", // 自定义公式 运算符
  numberDataFormatNum: 100, // 自定义公式 运算数
  numberDataFormatToFixed: 2, // 自定义公式 小数位
  numberDataFormatToSymbol: "", // 自定义公式 显示符号
  hidden: false, // 字段是否隐藏
  link: [], // 联动相关配置
  isDateComplete: false // 开启日期补全
}
// 数据字段类型
export const dataTypeMap = ref([
  { value: "string", label: "文本" },
  { value: "int", label: "数字" },
  { value: "img", label: "图片" },
  {
    value: "date",
    label: "日期",
    children: [
      { value: "yyyy", label: "yyyy" },
      { value: "yyyyMM", label: "yyyyMM" },
      { value: "yyyy/MM", label: "yyyy/MM" },
      { value: "yyyy-MM", label: "yyyy-MM" },
      { value: "yyyyMMdd", label: "yyyyMMdd" },
      { value: "yyyy/MM/dd", label: "yyyy/MM/dd" },
      { value: "yyyy-MM-dd", label: "yyyy-MM-dd" },
      { value: "yyyyMMdd HH:mm:ss", label: "yyyyMMdd HH:mm:ss" },
      { value: "yyyy/MM/dd HH:mm:ss", label: "yyyy/MM/dd HH:mm:ss" },
      { value: "yyyy-MM-dd HH:mm:ss", label: "yyyy-MM-dd HH:mm:ss" }
    ]
  },
  // 地理
  {
    value: "geo",
    label: "地理",
    children: [
      // 省/直辖市
      { value: "province", label: "省/直辖市" },
      // 市
      { value: "city", label: "市" },
      // 区 / 县
      { value: "district", label: "区/县" },
      // 经度
      { value: "longitude", label: "经度" },
      // 纬度
      { value: "latitude", label: "纬度" }
    ]
  }
])
export const aggregateTypeMap = [
  { value: "", label: "无聚合" },
  { value: "SUM", label: "求和" },
  { value: "COUNT", label: "计数" },
  { value: "COUNT_UNIQ", label: "计数(去重)" },
  { value: "MAX", label: "最大值" },
  { value: "MIN", label: "最小值" },
  { value: "AVG", label: "平均值" }
]
export const aggregateTypeMapFind = (value) => {
  return aggregateTypeMap.find((item) => item.value === value).label
}
export const fieldDateFormats = [
  { value: "yyyy", label: "yyyy" },
  { value: "yyyyMM", label: "yyyyMM" },
  { value: "yyyy/MM", label: "yyyy/MM" },
  { value: "yyyy-MM", label: "yyyy-MM" },
  { value: "yyyyMMdd", label: "yyyyMMdd" },
  { value: "yyyy/MM/dd", label: "yyyy/MM/dd" },
  { value: "yyyy-MM-dd", label: "yyyy-MM-dd" },
  { value: "yyyyMMdd HH:mm:ss", label: "yyyyMMdd HH:mm:ss" },
  { value: "yyyy/MM/dd HH:mm:ss", label: "yyyy/MM/dd HH:mm:ss" },
  { value: "yyyy-MM-dd HH:mm:ss", label: "yyyy-MM-dd HH:mm:ss" },
  { value: "HH", label: "HH" },
  { value: "HH:mm", label: "HH:mm" },
  { value: "HHmm", label: "HHmm" },
  { value: "HH:mm:ss", label: "HH:mm:ss" },
  { value: "HHmmss", label: "HHmmss" }
]
export const dateTypeMode = [
  { value: "year", label: "年" },
  { value: "month", label: "月" },
  { value: "day", label: "日" }
]
export const timeTypeMap = {
  yyyy: "年",
  yyyyMM: "月",
  yyyy_MM: "月",
  yyyy$MM: "月",
  yyyyMMdd: "日",
  yyyy_MM_dd: "日",
  yyyy$MM$dd: "日",
  yyyyMMddhh$mm$ss: "秒",
  yyyy_MM_ddhh$mm$ss: "秒",
  yyyy$MM$ddhh$mm$ss: "秒",
  hh: "时",
  hh$mm: "分",
  hh$mm$ss: "秒"
}
export const timeAppendMap = {
  year: "年",
  month: "月",
  date: "日",
  time: "秒",
  hour: "时",
  minute: "分",
  second: "秒"
}
export const columnKeys = [
  "aggregationType",
  "columnAttr",
  "columnComment",
  "columnName",
  "columnSql",
  "columnTitle",
  "cubeColumnId",
  "dimensionType",
  "numberDataFormat",
  "extJson",
  "tableAliasName",
  "tableName",
  "timeDataFormat",
  "viewDataType",
  "oldViewDataType",
  "type",
  "zuan",
  "virtualAggregationStatus"
]
export const condition = {
  NUMBER: [
    { function: "=", label: "=等于" },
    { function: "<>", label: "!=不等于" },
    { function: "<", label: "<小于" },
    { function: "<=", label: "<=小于等于" },
    { function: ">", label: ">大于" },
    { function: ">=", label: ">=大于等于" },
    { function: "isnull", label: "为空" },
    { function: "notnull", label: "不为空" }
  ],
  STRING: [
    { function: "=", label: "精准匹配" },
    { function: "like", label: "模糊匹配" },
    { function: "leftLike", label: "开头匹配" },
    { function: "rightLike", label: "结尾匹配" },
    { function: "notLike", label: "不匹配" },
    { function: "isNull", label: "为空" },
    { function: "notNull", label: "不为空" }
  ],
  DATETIME: [
    { function: "=", label: "=等于" },
    { function: ">=", label: ">=开始于" },
    { function: "<=", label: "<=结束于" }
  ],
  // 范围
  RANGETIME: [
    { function: ">=", label: ">=开始于" },
    { function: "<=", label: "<=结束于" }
  ]
}

export const globalFunctions = {
  NUMBER: [
    { function: "eq", label: "等于" },
    { function: "gt", label: "大于" },
    { function: "ge", label: "大于等于" },
    { function: "lt", label: "小于" },
    { function: "le", label: "小于等于" },
    { function: "between", label: "区间" },
    { function: "single", label: "单选" }
  ],
  STRING: [
    { function: "like", label: "匹配" },
    { function: "in", label: "包含" },
    { function: "eq", label: "等于" }
  ],
  DATETIME: [{ function: "between", label: "区间" }],
  APIS: [
    { function: "like", label: "匹配" },
    { function: "eq", label: "单选" }
  ]
}
export const noIncludesGridHeader = ["new-filter", "new-datetime", "new-edit", "new-text"]

export const apiTypeMap = {
  string: "字符串",
  number: "数字",
  date: "日期",
  month: "月份",
  time: "时间",
  timestamp: "时间戳"
}

export const chartThemeTemplateMap = [
  { title: "白色", themeTemplate: "login", theme: "black", chartBigdataTheme: "shine" },
  { title: "深蓝", themeTemplate: "bg22", theme: "white", chartBigdataTheme: "shine" },
  { title: "星空", themeTemplate: "bg23", theme: "white", chartBigdataTheme: "shine" },
  { title: "科技", themeTemplate: "bg21", theme: "white", chartBigdataTheme: "roma" },
  { title: "鲜艳", themeTemplate: "bg20", theme: "white", chartBigdataTheme: "shine" },
  { title: "湛蓝", themeTemplate: "bg24", theme: "white", chartBigdataTheme: "shine" },
  { title: "天空", themeTemplate: "bg25", theme: "white", chartBigdataTheme: "shine" },
  { title: "自定义", themeTemplate: "custom", theme: "white", chartBigdataTheme: "shine" }
]

//数据源类型
export const dataSourceType = [
  { value: "mysql", label: "MySQL", port: 3306 },
  { value: "oracle", label: "Oracle", port: 1521 },
  { value: "sqlsrv", label: "SQL Server", port: 1433 },
  { value: "pgsql", label: "PostgreSQL", port: 5432 },
  { value: "mongo", label: "MongoDb", port: 27017 }
]

// 数据字段类型
export const dataType = {
  // 数字类型
  numeral: ["tinyint", "smallint", "mediumint", "int", "bigint", "float", "double", "decimal", "bigint"],
  // 时间类型
  datetime: ["date", "datetime", "timestamp", "time", "year"]
}

// 字体粗细
export const fontWeight = [
  { value: "normal", label: "正常" },
  { value: "bold", label: "加粗" },
  { value: "bolder", label: "更粗" },
  { value: "lighter", label: "细体" }
]

// 描边类型
export const strokeType = [
  { value: "solid", label: "实线" },
  { value: "dashed", label: "虚线" }
]

// label位置
export const labelPosition = [
  { value: "top", label: "顶部" },
  { value: "bottom", label: "底部" },
  { value: "left", label: "左侧" },
  { value: "right", label: "右侧" },
  { value: "inside", label: "内部" },
  { value: "insideLeft", label: "内部左侧" },
  { value: "insideRight", label: "内部右侧" },
  { value: "insideTop", label: "内部顶部" },
  { value: "insideBottom", label: "内部底部" },
  { value: "insideTopLeft", label: "内部左上" },
  { value: "insideBottomLeft", label: "内部左下" },
  { value: "insideTopRight", label: "内部右上" },
  { value: "insideBottomRight", label: "内部右下" }
]

// 左侧位置
export const leftPosition = [
  { value: "left", label: "左侧" },
  { value: "right", label: "右侧" },
  { value: "center", label: "居中" }
]

// 上侧位置
export const topPosition = [
  { value: "top", label: "顶部" },
  { value: "bottom", label: "底部" },
  { value: "middle", label: "居中" }
]

// 表单大小
export const formSize = [
  { value: "mini", label: "超小" },
  { value: "small", label: "小" },
  { value: "medium", label: "中" },
  { value: "large", label: "大" }
]

// 表单标签对齐
export const formLabelAlign = [
  { value: "left", label: "左对齐" },
  { value: "right", label: "右对齐" },
  { value: "top", label: "顶部对齐" }
]
